	
// EnumDatoNotat.h : Declaration of the CEnumDatoNotat

#ifndef __ENUMDATONOTAT_H_
#define __ENUMDATONOTAT_H_

#include "resource.h"       // main symbols
#include "importado.h"
#include "database.h"
#include "datonotat.h"

/////////////////////////////////////////////////////////////////////////////
// CEnumDatoNotat
class ATL_NO_VTABLE CEnumDatoNotat : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<CEnumDatoNotat, &CLSID_EnumDatoNotat>,
	public ISupportErrorInfo,
	public IDispatchImpl<IEnumDatoNotat, &IID_IEnumDatoNotat, &LIBID_EBASDLLLib>
{
public:
	CEnumDatoNotat();
	virtual ~CEnumDatoNotat();

DECLARE_REGISTRY_RESOURCEID(IDR_ENUMDATONOTAT)
DECLARE_NOT_AGGREGATABLE(CEnumDatoNotat)
DECLARE_GET_CONTROLLING_UNKNOWN()

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CEnumDatoNotat)
	COM_INTERFACE_ENTRY(IEnumDatoNotat)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
	COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
END_COM_MAP()

	HRESULT FinalConstruct()
	{
		return CoCreateFreeThreadedMarshaler(
			GetControllingUnknown(), &m_pUnkMarshaler.p);
	}

	void FinalRelease()
	{
		m_pUnkMarshaler.Release();
	}

	CComPtr<IUnknown> m_pUnkMarshaler;

// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IEnumDatoNotat
public:
	STDMETHOD(Clone)(/*[out]*/ IEnumeration ** ppEnumeration);
	STDMETHOD(Reset)();
	STDMETHOD(Skip)(/*[in]*/ ULONG cItems);
	STDMETHOD(Next)(/*[out]*/ IUnknown ** ppUnk, /*[out]*/ ULONG * pcFetched);
	STDMETHOD(set_StudentGuid)(BSTR newVal) {
		m_studGuid = newVal;
		return S_OK;
	}
	STDMETHOD(findDatoNotat)(BSTR dato, IDatoNotat ** ppUnk);
private:
	_RecordsetPtr m_records;
	bool m_first;
	ULONG m_pos;
	ULONG m_length;
	bstr_t m_studGuid;
};

#endif //__ENUMDATONOTAT_H_
